package com.lifeng.patterns.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;

/**
 * @description:获取spring上下文
 * @author: lifeng
 * @create: 2020/9/21 15:28
 */
@Configuration
public class ApplicationContextUtils implements ApplicationContextAware {
    public static ConfigurableApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        ApplicationContextUtils.applicationContext = (ConfigurableApplicationContext) applicationContext;
    }
}
